﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    public class KaoHe_AttatchmentModel
    {
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private int _MainID;
        [DataMember]
        public int MainID
        {
            get { return _MainID; }
            set { _MainID = value; }
        }

        private string _Key;
        [DataMember]
        public string Key
        {
            get { return _Key; }
            set { _Key = value; }
        }

        private string _filename;
        [DataMember]
        public string filename
        {
            get { return _filename; }
            set { _filename = value; }
        }

        private string _realname;
        [DataMember]
        public string realname
        {
            get { return _realname; }
            set { _realname = value; }
        }

        public static KaoHe_AttatchmentModel FillEntity(DataRow dr)
        {
            KaoHe_AttatchmentModel right = new KaoHe_AttatchmentModel();
            if (dr.Table != null && dr.Table.Columns.Contains("MainID"))
                right.MainID = Convert.ToInt32(dr["MainID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("ID")) right.ID = Convert.ToInt32(dr["ID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("Key"))
                if (!string.IsNullOrEmpty(dr["Key"].ToString())) right.Key = dr["Key"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("filename"))
                if (!string.IsNullOrEmpty(dr["filename"].ToString()))
                    right.filename = dr["filename"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("realname"))
                if (!string.IsNullOrEmpty(dr["realname"].ToString())) right.realname = dr["realname"].ToString();
            return right;
        }
    }
}
